/*
package com.tensai.study.java.supper.branch;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.actor.UntypedActor;
import akka.japi.Creator;
import akka.japi.Pair;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;

public class Actor {

    private static final String MAN = "man";
    private static final String WOMAN = "woman";
    private static final String WC_EVENT= "想上厕所";
    @Data
    @Slf4j
    static class Person extends UntypedActor {
        private String gender;
        private String name;

        public static Props props(final String name, final String gender) {
            return Props.create(new Creator<Person>() {
                private static final long serialVersionUID = 1L;
                @Override
                public Person create() throws Exception {
                    Person p = new Person();
                    p.setGender(gender);
                    p.setName(name);
                    return p;
                }
            });
        }
        @Override
        public void onReceive(Object message) throws Throwable {
            Pair<String, ActorRef> m = (Pair<String,ActorRef>)message;
            log.info(name + m.getLeft());
            m.getRight().tell(this, ActorRef.noSender());

        }
    }

    @Data
    @Slf4j
    static class Toilet extends UntypedActor {
        private static final Map<String, Consumer<String>> FUNC_MAP = new ConcurrentHashMap<>();
        static {
            FUNC_MAP.put(MAN,person -> log.info(person + "应该去男厕所"));
            FUNC_MAP.put(WOMAN,person -> log.info(person + "应该去女厕所"));
        }

        public void wc(Person p ){
            FUNC_MAP.get(p.getGender()).accept(p.getName());
        }

        public static Props props() {
            return Props.create(Toilet.class);
        }

        @Override
        public void onReceive(Object message) throws Throwable {
            Person p = (Person) message;
            wc(p);
        }
    }

    public static void main(String[] args) {
        ActorSystem actorSystem = ActorSystem.create();
        ActorRef person = actorSystem.actorOf(Person.props("张三",MAN), "ZhangSan");
        ActorRef toilet = actorSystem.actorOf(Toilet.props(), "Toilet");
        Pair<String,ActorRef> message = Pair.of(WC_EVENT,toilet);
        person.tell(message,ActorRef.noSender());
    }
}
*/
